package com.a.b.c.d.e.curls;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;
/**
 * Created on 2021/10/8.
 *
 * @author yanshuchun
 */
public class BLClass {
    public static void main(String[] args) throws IOException {
        System.out.println(System.currentTimeMillis());

        URL url = new URL("fields1=f1,f2,f3,f4,f5&fields2=f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61&fqt=0&end=20181010&ut=fa5fd1943c7b386f172d6893dbfba10b&klt=101&secid=1.600900&fqt=1&lmt=1000&_=1633658043313");
        HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
        httpConn.setRequestMethod("GET");

        httpConn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:92.0) Gecko/20100101 Firefox/92.0");
        httpConn.setRequestProperty("Accept", "*/*");
        httpConn.setRequestProperty("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
        httpConn.setRequestProperty("DNT", "1");
        httpConn.setRequestProperty("Connection", "keep-alive");
        httpConn.setRequestProperty("Referer", "http://data.eastmoney.com/");
        httpConn.setRequestProperty("Pragma", "no-cache");
        httpConn.setRequestProperty("Cache-Control", "no-cache");

        httpConn.setRequestProperty("Cookie", "em_hq_fls=js; HAList=f-0-000001-%u4E0A%u8BC1%u6307%u6570; qgqp_b_id=2ec8296ad6c6e46a1b54f86ac5c9c812; st_si=60577181979583; st_sn=9; st_psi=20211008095403709-113300301471-1472542649; st_asi=delete; cowCookie=true; intellpositionL=1522.4px; intellpositionT=1364px; cowminicookie=true; st_pvi=19958116574134; st_sp=2021-09-27%2014%3A51%3A33; st_inirUrl=https%3A%2F%2Fwww.baidu.com%2Flink");

        InputStream responseStream = httpConn.getResponseCode() / 100 == 2
                ? httpConn.getInputStream()
                : httpConn.getErrorStream();
        Scanner s = new Scanner(responseStream).useDelimiter("\\A");
        String response = s.hasNext() ? s.next() : "";
        System.out.println(response);
    }
}
